home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 14 / Hot Mix 14.iso / HTML / vendors / heeg / InstallIt2 < prev    next >
Text File  |  1996-07-16  |  11KB  |  361 lines

  1. #!/bin/csh -f
  2.  
  3. #   This is an example installation script for HotMix.
  4. #
  5. #   The bulk of the code in this script is aimed at determining the
  6. #   INST_PATH -- the place to install the software (this isn't as
  7. #   easy as it might initially seem!).  The default is to copy to an
  8. #   installation directory in /usr/tmp.  If /usr/tmp doesn't exist,
  9. #   there is not enough disk space, or the user prefers another directory,
  10. #   the script will ask for another directory name.  In this case,
  11. #   the script will read the desired directory name, check its validity,
  12. #   check the available disk space, and if everything is OK, will then
  13. #   do the installation.
  14. #
  15. #   To customize the script, you will need to change these 4 parameters:
  16. #
  17. #       MYAPP = name of the application
  18. #
  19. #       INST_DIR = name of the installation directory
  20. #                  (this is the directory name, not the full path name)
  21. #       CD_PATH = directory path of the location of the software
  22. #                 on the HotMix CD-ROM (it must begin with "$HOTMIXDIR",
  23. #                 which is the mount point for the CD-ROM drive).
  24. #       KBYTES_REQ = required size of the full installation (in Kbytes).
  25. #
  26. #   In this simple example, the installation just involves copying
  27. #   the software to the hard disk, and then launching the application.
  28. #   In other cases, the installation will probably be more complicated,
  29. #   so you'll need to change the code at the end of the script as well.
  30. #   The rest of the script should not require modification.
  31. #
  32. #   All of the InstallIt and RemoveIt scripts should reside in the
  33. #   $CD_PATH directory.
  34. #
  35. #                                                 
  36. #
  37. #                                                 
  38.  
  39.  
  40.  
  41. set MYAPP=diver
  42. set INST_DIR=heeg
  43. set CD_PATH=$HOTMIXDIR/HTML/vendors/heeg
  44. set KBYTES_REQ=10000
  45.  
  46. #
  47. #  Test to see if on the new Indy filesystem or old one.
  48. #
  49.  
  50. set TEST_NEW=`df -k /usr | /usr/bin/awk '{print $7}'`
  51.  
  52. if ( "$TEST_NEW" == "Mounted /" ) then
  53.    set FILE_STRUCTURE=new
  54.  
  55. else
  56.    set FILE_STRUCTURE=old
  57. endif
  58.  
  59.  
  60. #
  61. #  Determine the INST_PATH name.
  62. #
  63. #  First try /usr/tmp;  then if necessary, ask for another directory.
  64. #
  65.  
  66. @ MBYTES_REQ = ($KBYTES_REQ) / 1000
  67.  
  68. if ( $FILE_STRUCTURE == "new" ) then
  69.    set KBYTES_AVAIL=`df -k / | /bin/grep / | /usr/bin/awk '{print $5}'`
  70. else
  71.    set KBYTES_AVAIL=`df -k /usr | /bin/grep /usr | /usr/bin/awk '{print $5}'`
  72. endif
  73.  
  74.  
  75. if ( -w /usr/tmp ) then
  76.  
  77.     if ( $KBYTES_AVAIL > $KBYTES_REQ ) then
  78.  
  79.         set INST_PATH=/usr/tmp/$INST_DIR
  80.  
  81.         echo " "
  82.         echo "This demo requires $MBYTES_REQ Mbytes of disk space."
  83.         echo " "
  84.         echo "It will be installed in a directory named $INST_PATH/visual"
  85.         echo "Is this OK (y/n)?  \c"
  86.         set ans=($<)
  87.         if ( $ans != 'y' ) then
  88.             echo " "
  89.             echo "Do you want to install in another directory (y/n)?  \c"
  90.             set ans2=($<)
  91.             if ( $ans2 != 'y' ) then
  92.                 echo " "
  93.                 echo "... Bye."
  94.                 sleep 3
  95.                 exit
  96.             else
  97.                 set INST_PATH=none
  98.             endif
  99.         else
  100.             if ( -d $INST_PATH ) then
  101.                 echo " "
  102.                 echo "It seems the demo is already installed.  Continue anyway (y/n)?  \c"
  103.                 set ans3=($<)
  104.                 if ( $ans3 != 'y' ) then
  105.                     echo " "
  106.                     echo "... Bye."
  107.                     sleep 3
  108.                     exit
  109.                 endif
  110.                 rm -rf $INST_PATH
  111.             endif
  112.         endif
  113.     else
  114.         set INST_PATH=none
  115.     endif
  116. else
  117.     set INST_PATH=none
  118. endif
  119.  
  120. if ( $INST_PATH == "none" ) then
  121.  
  122. #   Read name of installation directory.
  123.  
  124.     echo " "
  125.     echo "This demo requires $MBYTES_REQ Mbytes of disk space."
  126.  
  127.     LOOP1:
  128.  
  129.     unset INSTDIR_FILESYS
  130.  
  131.     echo " "
  132.     echo "Enter the full path name of an existing directory"
  133.     echo "in which to copy the software (or enter 'q' to quit):  \c"
  134.     set ans=($<)
  135.  
  136. #   Check validity of the path name.  If it contains only a "/",
  137. #   this will cause a divide by zero, and fail.
  138.     set TEST1=`echo $ans | cut -f2 -d"/"`
  139.     if ( ! $#TEST1 ) then
  140.             echo " "
  141.             echo "You cannot use directory /.  Please try again."
  142.             goto LOOP1
  143.     endif
  144.  
  145.     if ( $ans == 'q' ) then
  146.         echo " "
  147.         echo "... Bye."
  148.         sleep 3
  149.         exit
  150.     else if ( $#ans == 0 ) then
  151.         echo " "
  152.         echo "Input error.  Please try again."
  153.         goto LOOP1
  154.     else
  155.  
  156. #       Check validity of the path name again.  It must begin with "/".
  157.         set TEST2=`echo $ans | cut -f2 -d"/" -s`
  158.         if ( ! $#TEST2 ) then
  159.                 echo " "
  160.                 echo "The pathname must begin with /.  Please try again."
  161.                 goto LOOP1
  162.         endif
  163.  
  164.         if ( -d $ans ) then
  165.  
  166.             echo " "
  167.             echo "A $INST_DIR directory will be created in $ans."
  168.             echo "Is this OK (y/n)?:  \c"
  169.             set ans2=($<)
  170.             if ( $ans2 != 'y' ) goto LOOP1
  171.  
  172. #           Determine the space available for the filesystem
  173. #           containing the requested directory.
  174. #
  175.  
  176. #                       Check to see if the directory is actually a link or an
  177. #                       nfs mount and do appropriate checks.
  178.  
  179.                         if ( -l $ans ) then
  180.                                 cd $ans
  181.                                 set CDIR=`pwd`
  182.                                 set KBYTES_AVAIL=`df -k $CDIR | /usr/bin/awk '{print $5}'`
  183.                         endif
  184.  
  185.                         touch $ans/hmtest
  186.                         if ( ! -r $ans/hmtest ) then
  187.  
  188.                                 echo "Can not write to $ans, please choose another directory."
  189.                                 goto LOOP1
  190.                         endif
  191.             /bin/rm -f $ans/hmtest
  192.  
  193.  
  194.  
  195. #           First, find all the mounted filesystems.
  196.             set FILESYSTEMS=`df -k | awk '{print $7}' | grep /`
  197.  
  198. #           Now, beginning with the full path name of the
  199. #           requested directory, start stripping off the trailing
  200. #           subdirectory names, and compare this to the existing
  201. #           file system names.  If these match exactly, then we've
  202. #           found the right file system.
  203.  
  204.             set TEST3=`echo $ans | cut -f3 -d"/"`
  205.             if ( ! $#TEST3 ) then
  206.                 set PATH=$ans
  207.             else
  208.                 set PATH=`dirname $ans`
  209.             endif
  210.             LOOP2:
  211.                 foreach FILESYSTEM ($FILESYSTEMS)
  212.  
  213. #                   Don't do the test if $FILESYSTEM == "/"
  214.                     set TEST4=`echo $FILESYSTEM | cut -f2 -d"/"`
  215.                     if ( $#TEST4 != 0 ) then
  216.  
  217.                         if ( $PATH == $FILESYSTEM ) then
  218.                             set INSTDIR_FILESYS=$PATH
  219.                         endif
  220.                     endif
  221.                 end
  222.                 set PATH=`dirname $PATH`
  223.  
  224. #           Continue looping until we've stripped the pathname
  225. #           down to only "/", or until we find the file system.
  226.  
  227.             set LOOPTEST=`echo $PATH | cut -f2 -d"/"`
  228.             if (( $#LOOPTEST != 0 ) && ( ! $?INSTDIR_FILESYS )) goto LOOP2
  229.  
  230.             if ( $?INSTDIR_FILESYS ) then
  231.  
  232. #               Determine the available space
  233.  
  234.                 set KBYTES_AVAIL=`df -k $INSTDIR_FILESYS | /bin/grep $INSTDIR_FILESYS | /usr/bin/awk '{print $5}'`
  235.  
  236.             else
  237.                 if ( $FILE_STRUCTURE == "new" ) then
  238.                   set KBYTES_AVAIL=`df -k / | /bin/grep / | /usr/bin/awk '{print $5}'`
  239.                 else
  240.                 echo " "
  241.                 echo "  ERROR:  Can't determine the amount of available disk"
  242.                 echo "          space for the directory you requested."
  243.                 echo " "
  244.                 echo "          Continue anyway (y/n)?  \c"
  245.                 set ans3=($<)
  246.                 if ( $ans3 == 'y' ) then
  247.                     @ KBYTES_AVAIL = ($KBYTES_REQ) + 1
  248.                 else
  249.                     echo " "
  250.                     echo "... Bye."
  251.                     sleep 3
  252.                     exit
  253.                 endif
  254.             endif
  255.        endif
  256.  
  257.             if ( $KBYTES_AVAIL > $KBYTES_REQ ) then
  258.                 if ( -w $ans ) then
  259.  
  260. #                   Success!!!
  261.  
  262.                     set INST_PATH=$ans/$INST_DIR
  263.                     echo " "
  264.                 else
  265.                     echo " "
  266.  
  267.                     echo "Can't write to directory $ans."
  268.                     echo "Please try again."
  269.                     goto LOOP1
  270.                 endif
  271.             else
  272.                 echo " "
  273.                 echo "Not enough space available."
  274.                 echo "Please try again."
  275.                 goto LOOP1
  276.             endif
  277.         else
  278.             echo " "
  279.             echo "Can't find directory $ans."
  280.             goto LOOP1
  281.         endif
  282.     endif
  283.  
  284.     # Check installation directory.
  285.     if ( -d $INST_PATH ) then
  286.         echo " "
  287.         echo "It seems the demo is already installed.  Continue anyway (y/n)?  \c"
  288.         set ans3=($<)
  289.         if ( $ans3 != 'y' ) then
  290.             echo " "
  291.             echo "... Bye."
  292.             sleep 3
  293.             exit
  294.         endif
  295.  
  296.         rm -rf $INST_PATH
  297.     endif
  298. endif
  299.  
  300. #  Store INST_PATH in a file so it can be communicated to the RemoveIt script.
  301. #
  302. #  First, try to put it in /usr/tmp.  If we can't, then put it in /tmp
  303. #  and in the user's home directory.  If put in /tmp, the file will
  304. #  disappear if the machine is rebooted.  If put in the user's home
  305. #  directory, we won't be able to find it if the user trying to remove
  306. #  the software is not the same as the user who installed it.  Either
  307. #  case isn't very good, but it's the best we can do if we can't write
  308. #  to /usr/tmp.
  309.  
  310. /bin/rm -f /usr/tmp/HOTMIXPATH_$INST_DIR > /dev/null
  311. /bin/rm -f /tmp/HOTMIXPATH_$INST_DIR > /dev/null
  312.  
  313. /bin/rm -f ~/HOTMIXPATH_$INST_DIR > /dev/null
  314.  
  315. if ( -w /usr/tmp ) then
  316.     echo "setenv INST_PATH $INST_PATH" > /usr/tmp/HOTMIXPATH_$INST_DIR
  317.     /bin/chmod 666 /usr/tmp/HOTMIXPATH_$INST_DIR
  318. else
  319.     echo "setenv INST_PATH $INST_PATH" > /tmp/HOTMIXPATH_$INST_DIR
  320.     /bin/chmod 666 /tmp/HOTMIXPATH_$INST_DIR
  321.  
  322.     echo "setenv INST_PATH $INST_PATH" > ~/HOTMIXPATH_$INST_DIR
  323.     /bin/chmod 666 ~/HOTMIXPATH_$INST_DIR
  324. endif
  325.  
  326. #
  327. #-----------------------------------------------------------------------
  328. #
  329. #  Now that we've finally determined INST_PATH, do the installation.
  330. #  In this case, just copy the software and execute the application.
  331.  
  332. echo " "
  333. echo "Installing Demo.  Please wait..."
  334.      mkdir $INST_PATH
  335.      cd $INST_PATH
  336.     zcat $HOTMIXDIR/HTML/vendors/heeg/visual.tar.Z | tar xvf -
  337. sleep 10
  338. echo " "
  339. echo "Done."
  340. echo " "
  341. echo "To run the demo:" 
  342. echo "Move to the $INST_PATH/visual directory"
  343. echo "and execute ./bin/visualworks visual.im."
  344. echo " "
  345. echo " "
  346. echo "You should also view the demo instructions"
  347. echo "in the $INST_PATH/visual directory. "
  348. echo " "
  349. echo "Do you want to run the demo now (y/n)?  \c"
  350. set ans=($<)
  351. if ( $ans == 'y' ) then
  352.     cd $INST_PATH/visual
  353.     ./bin/visualworks ./image/visual.im &
  354. else
  355.     echo "... Bye."
  356.     sleep 3
  357. endif
  358. echo "Press Enter to exit this window...  \c"
  359. set a = $<
  360.  
  361.